import {
  USERINFO,
  LOGIN_TOKEN_KEY,
  MOBILE,
  BINDSTAFFCARDID,
  ISBINDSTAFF,
  AUTHORIZEPHONESTATUS,
  ISVERIFIED,
  FORWARDUSERID,
  ALLINITCOMPLTET,
} from "../constants/userInfo";

const INITIAL_STATE = {
  __userInfo: {gov:false},
  forwardUserId: null,
  token: null,
  mobile: null,
  __isBindStaff: false,
  __bindStaffCardId: null,
  __authorizePhoneStatus: { authorizeStatus: 0, mobile: "", switchStatus: 0 },
  __isVerified: 0, // 是否身份认证
  __allInitComplete: false, // 是否数据都加载完成
};

export default function userInfo(state = INITIAL_STATE, action) {
  switch (action.type) {
    case LOGIN_TOKEN_KEY:
      return {
        ...state,
        token: action.payload,
      };
    case USERINFO:
      return {
        ...state,
        __userInfo: action.payload,
      };
    case FORWARDUSERID:
      return {
        ...state,
        forwardUserId: action.payload,
      };
    case MOBILE:
      return {
        ...state,
        mobile: action.payload,
      };
    case ISBINDSTAFF:
      return {
        ...state,
        __isBindStaff: action.payload,
      };
    case BINDSTAFFCARDID:
      return {
        ...state,
        __bindStaffCardId: action.payload,
      };
    case AUTHORIZEPHONESTATUS:
      return {
        ...state,
        __authorizePhoneStatus: action.payload,
      };
    case ISVERIFIED:
      return {
        ...state,
        __isVerified: action.payload,
      };
    case ALLINITCOMPLTET:
      return {
        ...state,
        __allInitComplete: action.payload,
      };
    default:
      return state;
  }
}
